Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize data size of Broadcast / Passthrough exchange operator #6880

Merged
merged 47 commits into from
Mar 3, 2023

Conversation

solotzg
Copy link
Contributor

@solotzg solotzg commented Feb 23, 2023

What problem does this PR solve?

Issue Number: ref #7084

after #6596

What is changed and how it works?

  • support data compression in broadcast/passthrough exchange
  • update parts of utils modules
  • For StorageDisaggregated, use latest mpp version for task meta.
    • TODO: enable data compression if necessary

image

Benchmark

ENV

Test Broadcast Exchange With Compression

Make broadcast exchange become bottleneck forcily

  • Set tidb_broadcast_join_threshold_count: 10240 -> 1024000
  • Set tidb_broadcast_join_threshold_size: 104857600 -> 10485760000
Time(s) Original Broadcast FAST Compression Improvement: Compression/Original - 1.0
Q13 14.36 11.11 29.25%

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

x
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
1
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
2
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
4
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
5
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
6
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
7
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
8
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 23, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • windtalker
  • yibin87

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 23, 2023
@solotzg
Copy link
Contributor Author

solotzg commented Mar 2, 2023

/run-integration-test

@solotzg solotzg requested review from SeaRise and removed request for guo-shaoge March 3, 2023 00:39
Copy link
Contributor

@SeaRise SeaRise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others LGTM

assertBlockSchema(expected_types, block, "BroadcastOrPassThroughWriter");
}

if (exchange_type == tipb::ExchangeType::Broadcast)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using template?

template <class ExchangeWriterPtr, bool is_broadcast>
class BroadcastOrPassThroughWriter : public DAGResponseWriter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also an optional way.

Comment on lines +102 to +106
if (!expected_types.empty())
{
for (auto && block : blocks)
assertBlockSchema(expected_types, block, "BroadcastOrPassThroughWriter");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about

Suggested change
if (!expected_types.empty())
{
for (auto && block : blocks)
assertBlockSchema(expected_types, block, "BroadcastOrPassThroughWriter");
}
#ifndef NDEBUG
if (!expected_types.empty())
{
for (auto && block : blocks)
assertBlockSchema(expected_types, block, "BroadcastOrPassThroughWriter");
}
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertBlockSchema is always neccesary when using compression because compression codec process will not check the expected types.

auto remote_tunnel_tracked_packet = local_tunnel_cnt == tunnel_cnt ? nullptr : ori_tracked_packet;

if (compression_method != CompressionMethod::NONE)
remote_tunnel_tracked_packet = MPPTunnelSetHelper::ToCompressedPacket(ori_tracked_packet, version, compression_method);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
remote_tunnel_tracked_packet = MPPTunnelSetHelper::ToCompressedPacket(ori_tracked_packet, version, compression_method);
remote_tunnel_tracked_packet = MPPTunnelSetHelper::ToCompressedPacket(remote_tunnel_tracked_packet, version, compression_method);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remote_tunnel_tracked_packet may be null if local_tunnel_cnt == tunnel_cnt. But I will refine this part and make it clear.

{
GET_METRIC(tiflash_exchange_data_bytes, type_hash_none_compression_local).Increment(sz);
local_cnt++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local_cnt++;
++local_cnt;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also an optional way, but there is no different for modern compiler.

}
else
{
GET_METRIC(tiflash_exchange_data_bytes, type_hash_none_compression_remote).Increment(sz);
remote_cnt++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
remote_cnt++;
++remote_cnt;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

static void broadcastOrPassThroughWriteImpl(
const size_t tunnel_cnt,
const size_t local_tunnel_cnt, // can be 0 for PassThrough writer
size_t ori_packet_bytes, // original data packet size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems unnecessary to pass ori_packet_bytes.
Why not auto local_tracked_packet_bytes = local_tracked_packet? local_tracked_packet->getPacket().ByteSizeLong() : 0;?

Copy link
Contributor Author

@solotzg solotzg Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ori_packet_bytes is used for present uncompressed size of data packet. Especially when local_tunnel_cnt is 0 and local_tracked_packet is NULL. It may occur when using Passthrough writer.

void updatePartitionWriterMetrics(CompressionMethod method, size_t original_size, size_t sz, bool is_local)
template <bool is_broadcast, typename FuncIsLocalTunnel, typename FuncWriteToTunnel>
static void broadcastOrPassThroughWriteImpl(
const size_t tunnel_cnt,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass remote_tunnel_cnt looks more symmetrical.

static void broadcastOrPassThroughWriteImpl(
    const size_t local_tunnel_cnt,
    const size_t remote_tunnel_cnt,
    TrackedMppDataPacketPtr && local_tracked_packet,
    TrackedMppDataPacketPtr && remote_tracked_packet,
    

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also an optional way.

dbms/src/Common/TiFlashMetrics.h Outdated Show resolved Hide resolved
dbms/src/Flash/Mpp/MPPTunnelSetHelper.cpp Outdated Show resolved Hide resolved
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
Signed-off-by: Zhigao Tong <tongzhigao@pingcap.com>
@solotzg
Copy link
Contributor Author

solotzg commented Mar 3, 2023

/merge

@ti-chi-bot
Copy link
Member

@solotzg: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 3b778c3

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 3, 2023
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Mar 3, 2023
@solotzg
Copy link
Contributor Author

solotzg commented Mar 3, 2023

/merge

@ti-chi-bot
Copy link
Member

@solotzg: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: ccb115c

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 3, 2023
@solotzg
Copy link
Contributor Author

solotzg commented Mar 3, 2023

/unhold

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2023
@ti-chi-bot ti-chi-bot merged commit 0ff2b96 into pingcap:master Mar 3, 2023
@solotzg solotzg deleted the bc-pass-exchange-compress branch March 4, 2023 06:30
@solotzg solotzg mentioned this pull request Mar 6, 2023
12 tasks
ti-chi-bot pushed a commit that referenced this pull request Mar 6, 2023
@solotzg solotzg mentioned this pull request Mar 16, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants